package xyz.jangle.design.observer;

import java.util.ArrayList;
import java.util.List;

public class ConcreteSubject implements Subject {
	
	private List<Observer> observers;

	public ConcreteSubject() {
		super();
		observers = new ArrayList<Observer>();
	}

	@Override
	public void addObserver(Observer observer) {
		if(!observers.contains(observer)) {
			observers.add(observer);
		}
	}

	@Override
	public void deleteObserver(Observer observer) {
		if(observers.contains(observer)) {
			observers.remove(observer);
		}
	}

	@Override
	public void notifyObserver() {
		for(Observer observer:observers) {
			observer.update();
		}

	}

}
